{% extends 'base.html' %}

{% load static %}
{% block extra_css %}
  <link rel="stylesheet" href="{% static 'css/password_change.css' %}">
{% endblock %}

{% block content%}
<div class="container">
    <div class="card">
        <!-- 标题 -->
        <div class="card-header">
            <h3>修改密码</h3>
        </div>

        <!-- 内容 -->
        <div class="card-body">

            <!-- 修改密码表单 -->
            <form method="post" novalidate>
                {% csrf_token %}
                <!-- 老密码 -->
                <div class="form-group">
                    <label for="{{ form.old_password.id_for_label }}">当前密码：</label>
                    {{ form.old_password }}
                    <!-- 异常处理1 -->
                    {% if form.old_password.errors %}
                        <span class="error">{{ form.old_password.errors|first }}</span>
                    {% endif %}
                </div>

                <!-- 新密码 -->
                <div class="form-group">
                    <label for="{{ form.new_password1.id_for_label }}">新密码：</label>
                    {{ form.new_password1 }}

                    <!-- 异常处理2 -->
                    {% if form.new_password1.errors %}
                        <span class="error">{{ form.new_password1.errors|first }}</span>
                    {% endif %}
                </div>

                <!-- 新密码重复 -->
                <div class="form-group">
                    <label for="{{ form.new_password2.id_for_label }}">确认新密码：</label>
                    {{ form.new_password2 }}

                    <!-- 异常处理3 -->
                    {% if form.new_password2.errors %}
                        <span class="error">{{ form.new_password2.errors|first }}</span>
                    {% endif %}
                </div>

                <!-- 表单提交按钮 -->
                <button type="submit" class="btn">确认修改</button>
                <a href="{% url 'users:profile' %}" class="btn cancel">取消</a>


            </form>
        </div>
    </div>
</div>
{% endblock %}